package gen_b2g.game;

import java.util.*;

import com.bowlong.util.*;
import com.bowlong.net.*;

import gen_b2g.game.bean.*;

@SuppressWarnings({ "rawtypes", "unchecked" })
public abstract class CallGameServiceI {

    public static int __pid;
    public TcpChannel chn;
    public CallGameServiceI(TcpChannel chn) {
        this.chn = chn;
    }

    // 登陆
    public void login(String token, String device, String deviceSystem, String deviceCode, String resolution, String language, String uuid, String pass, String version, String channel, int serverId, int loginType) throws Exception {
        Map _map = new HashMap();
        _map.put(-100, __pid);  // _pid
        _map.put(0, 103149417);  // cmd:login
        _map.put(110541305, token);
        _map.put(-1335157162, device);
        _map.put(-923409371, deviceSystem);
        _map.put(780674403, deviceCode);
        _map.put(-1600030548, resolution);
        _map.put(-1613589672, language);
        _map.put(3601339, uuid);
        _map.put(3433489, pass);
        _map.put(351608024, version);
        _map.put(738950403, channel);
        _map.put(1379103678, serverId);
        _map.put(-1719265725, loginType);
        chn.send(_map);
    }

    // ping
    public void ping(String str) throws Exception {
        Map _map = new HashMap();
        _map.put(-100, __pid);  // _pid
        _map.put(0, 3441010);  // cmd:ping
        _map.put(114225, str);
        chn.send(_map);
    }

    // 提交新手任务步奏
    public void submitNewTaskIndex(int index) throws Exception {
        Map _map = new HashMap();
        _map.put(-100, __pid);  // _pid
        _map.put(0, -1538971451);  // cmd:submitNewTaskIndex
        _map.put(100346066, index);
        chn.send(_map);
    }

    // 设置昵称密码
    public void setNameAndPass(String name, String pass) throws Exception {
        Map _map = new HashMap();
        _map.put(-100, __pid);  // _pid
        _map.put(0, 1193247675);  // cmd:setNameAndPass
        _map.put(3373707, name);
        _map.put(3433489, pass);
        chn.send(_map);
    }


    public static final Set<Integer> CMD = NewSet.create(103149417,3441010,-1538971451,1193247675);

    public static boolean in(NewMap map) throws Exception {
        int cmd = map.getInt(0);
        return CMD.contains(cmd);
    }

    // //////////////////////////////////////////////
    // 逻辑分发
    // //////////////////////////////////////////////

    public void disp(NewMap map) throws Exception {
        int cmd = map.getInt(0);
        disp(cmd, map);
    }
    public void disp(int cmd, NewMap map) throws Exception {
        switch (cmd) {
            case 103149417: { //  登陆
                __onCallback_login(map);
                return;
            }
            case 3441010: { //  ping
                __onCallback_ping(map);
                return;
            }
            case -1538971451: { //  提交新手任务步奏
                __onCallback_submitNewTaskIndex(map);
                return;
            }
            case 1193247675: { //  设置昵称密码
                __onCallback_setNameAndPass(map);
                return;
            }
        }
        throw new Exception(" cmd: " + cmd + ":" + map + " not found processor.");
    }


    // //////////////////////////////////////////////
    // 参数解析
    // //////////////////////////////////////////////

    // 登陆
    private void __onCallback_login(NewMap map2) throws Exception {
        NewMap retVal = map2.getNewMap(1);
        ReturnStatus rst = ReturnStatus.parse(retVal);
        NUser nUser = null; // def var
        if(rst.succ >= 0) {
          nUser = NUser.parse(map2.getNewMap(104233305));
        }

        onLogin(nUser, rst);
    }

    // ping
    private void __onCallback_ping(NewMap map2) throws Exception {
        NewMap retVal = map2.getNewMap(1);
        ReturnStatus rst = ReturnStatus.parse(retVal);
        NStr rst2 = null; // def var
        if(rst.succ >= 0) {
          rst2 = NStr.parse(map2.getNewMap(3510335));
        }

        onPing(rst2, rst);
    }

    // 提交新手任务步奏
    private void __onCallback_submitNewTaskIndex(NewMap map2) throws Exception {
        NewMap retVal = map2.getNewMap(1);
        ReturnStatus rst = ReturnStatus.parse(retVal);

        onSubmitNewTaskIndex(rst);
    }

    // 设置昵称密码
    private void __onCallback_setNameAndPass(NewMap map2) throws Exception {
        NewMap retVal = map2.getNewMap(1);
        ReturnStatus rst = ReturnStatus.parse(retVal);

        onSetNameAndPass(rst);
    }


    // //////////////////////////////////////////////
    // 需要实现的接口
    // //////////////////////////////////////////////

    // 登陆
    public void onLogin(NUser nUser, ReturnStatus val) throws Exception {};

    // ping
    public void onPing(NStr rst2, ReturnStatus val) throws Exception {};

    // 提交新手任务步奏
    public void onSubmitNewTaskIndex(ReturnStatus val) throws Exception {};

    // 设置昵称密码
    public void onSetNameAndPass(ReturnStatus val) throws Exception {};

}
